package com.coco.controller;

import com.coco.model.CollectionCondition;
import com.coco.model.VideoModel;
import com.coco.service.CollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author GHOSTLaycoo
 * @date 2020/4/26 - 9:53
 */
@RestController
@RequestMapping("collection")
public class CollectionController {

    @Autowired
    private CollectionService collectionService;

    @ApiOperation(value = "保存收藏")
    @PostMapping("/saveCollection")
    public ResponseEntity<Integer> saveCollection(@RequestBody CollectionCondition collectionCondition){
        return ResponseEntity.ok(collectionService.saveCollection(collectionCondition));
    }

    @ApiOperation(value = "删除收藏")
    @PostMapping("/deleteCollection")
    public ResponseEntity<Integer> deleteCollection(@RequestBody CollectionCondition collectionCondition){
        return ResponseEntity.ok(collectionService.deleteCollection(collectionCondition));
    }

    @ApiOperation(value = "搜索")
    @PostMapping("/selectCollection")
    public ResponseEntity<Integer> selectCollection(@RequestBody CollectionCondition collectionCondition){
        return ResponseEntity.ok(collectionService.selectCollection(collectionCondition));
    }

    @ApiOperation(value = "通过userId查询收藏数据")
    @GetMapping("/selectCollectionByUserId/{userId}")
    public ResponseEntity<List<VideoModel>> selectCollectionByUserId(@PathVariable("userId") String userId){
        return ResponseEntity.ok(collectionService.selectCollectionByUserId(userId));
    }

}
